package com.lagou.utils;

import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

public class StringConverter implements Converter<Date, String> {

    @Override
    public String convert(Date date) {
        //将日期转给成字符串yyyy-MM-dd
        if(date == null) return null;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(date);
        return dateString;
    }
}
